home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / hypercrd / hc2_x / tcprogud.sit / TC Prog Guide / card_38494.txt < prev    next >
Text File  |  1991-02-27  |  2KB  |  20 lines

  1. -- card: 38494 from stack: in
  2. -- bmap block id: 0
  3. -- flags: 0000
  4. -- background id: 4755
  5. -- name: 
  6.  
  7.  
  8. -- part contents for background part 6
  9. ----- text -----
  10. 4.3  TC Indirect & Direct Objects
  11.  
  12. -- part contents for background part 4
  13. ----- text -----
  14. This Section does not apply to C++.  Most TC classes are defined using the 'indirect' specifier, or are descended from a class using this specifier.  When a pointer to an object of this type is declared, the pointer is actually implemented as a HANDLE.  Macintosh handles are pointers to pointers.  Using handles to refer to data allows the Macintosh memory management routines to dynamically restructure memory ("move memory") during program execution without disturbing the program.  Since the TC compiler is aware what identifiers refer to objects, it allows the programmer to treat the identifiers as simple pointers without concern for the actual implementation as handles.  There are a few situations, however, where awareness of this implementation is crucial.
  15.  
  16. Most significant is the rule:  never rely upon the ADDRESS of an instance variable during calls to functions which invoke memory management routines.  The actual address may change during memory management due to the handle implementation, causing "inexplicable" program crashes.  Unfortunately many of TC's functions in the standard C libraries invoke memory management.  For example, in the Student::set() method defined earlier we may instead wish to obtain the student number at run-time from the user using the scanf() library function:
  17.  
  18. -- part contents for background part 7
  19. ----- text -----
  20. 123